package com.andware.volley.toolbox;

import android.annotation.SuppressLint;
import android.os.Build.VERSION;

import java.net.CookieHandler;
import java.net.CookieManager;
import java.net.CookiePolicy;
import java.net.CookieStore;

/**
 * Created by ishishuji on 14-8-22.
 */
public class HurlCookieStack extends HurlStack {

    private CookieManager cookieHandler;

    public HurlCookieStack () {
        super ();
        if ( VERSION.SDK_INT >= 9 ) {

            cookieHandler = new CookieManager ( null, CookiePolicy.ACCEPT_ALL );

            CookieHandler.setDefault ( cookieHandler );

        }
    }

    @SuppressLint ("NewApi")
    public CookieStore getCookieStore () {
        return cookieHandler.getCookieStore ();
    }
}
